//
//  SPDeleteTextFiledView.m
//  Sampux
//
//  Created by rzm on 16/9/12.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "SPDeleteTextFiledView.h"

@interface SPDeleteTextFiledView ()

@end

@implementation SPDeleteTextFiledView
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
    }
    return self;
}
- (void)createDeleteTextFiledWithPlaceholder:(NSString *)placeholder andLeftImage:(NSString *)leftImg andRightImage:(NSString *)rightImg
{
    UIView *backView = [[UIView alloc]initWithFrame:self.bounds];
    [self addSubview:backView];
    _deleteBtn = [UIButton createButton];
    _deleteBtn.frame = CGRectMake(backView.width - 30, 0, 30, self.height);
    [backView addSubview:_deleteBtn];
    [_deleteBtn setImage:imageNamed(rightImg) forState:UIControlStateNormal];
    [_deleteBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    _deleteBtn.hitTestEdgeInsets = UIEdgeInsetsMake(- 10, -20, -10, -20);
    
    _textFiled = [UITextField createTextFieldWithRect:CGRectMake(0, 0,  _deleteBtn.x - 5, backView.height) andPlaceholder:placeholder andLeftImage:leftImg];
    [backView addSubview:_textFiled];
    [UIView createLineViewInbottom:backView];
}

- (void)btnClick:(UIButton *)btn
{
    _textFiled.text = @"";
}
@end
